﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Reflection;

namespace QL_Truong_Hoc
{
    public partial class frmChonLopVanHoa : DevExpress.XtraEditors.XtraForm
    {
        public bool Selected { get; set; }
        public int KhungDaoTaoID { get; set; }
        public int TrinhDoDaoTaoID { get; set; }
        public int KhoaID { get; set; }
        public int KhoasID { get; set; }
        public int NgheID { get; set; }
        public int LopID { get; set; }

        public string KhungDaoTaoTen { get; set; }
        public string TrinhDoDaoTaoTen { get; set; }
        public string KhoaTen { get; set; }
        public string KhoasTen { get; set; }
        public string NgheTen { get; set; }
        public string LopTen { get; set; }

        public frmChonLopVanHoa()
        {
            InitializeComponent();
        }

        private void frmChonKhungDaoTao_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLTHDataSet.mKhoaHoc' table. You can move, or remove it, as needed.
            this.mKhoaHocTableAdapter.Fill(this.qLTHDataSet.mKhoaHoc);
            // TODO: This line of code loads data into the 'qLTHDataSet.mTrinhDoDaoTao' table. You can move, or remove it, as needed.
            this.mTrinhDoDaoTaoTableAdapter.Fill(this.qLTHDataSet.mTrinhDoDaoTao);
            // TODO: This line of code loads data into the 'qLTHDataSet.mLopVanHoaSelectAllWithDetail' table. You can move, or remove it, as needed.
            this.mLopVanHoaSelectAllWithDetailTableAdapter.Fill(this.qLTHDataSet.mLopVanHoaSelectAllWithDetail);

            this.Selected = false;
        }

        private void btnChoose_Click(object sender, EventArgs e)
        {
            try
            {
                //lấy dữ liệu
                this.LopID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colLVH_ID));

                if (this.LopID <= 0)
                {
                    clsCommon.fncMsgInfo("Hãy chọn một lớp học.");
                    dgvKhung.Focus();
                    return;
                }

                //this.KhungDaoTaoID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKDT_ID));
                this.TrinhDoDaoTaoID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colTD_ID));
                //this.KhoaID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKH_ID));
                this.KhoasID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colKHS_ID));
                //this.NgheID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colNG_ID));
                this.LopID = clsCommon.fncCnvNullToInt(dgvKhung.GetFocusedRowCellValue(colLVH_ID));

                //this.KhungDaoTaoTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colKDT_ID));
                this.TrinhDoDaoTaoTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colTD_ID));
                //this.KhoaTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colKH_ID));
                this.KhoasTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colKHS_ID));
                //this.NgheTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colNG_ID));
                this.LopTen = clsCommon.fncCnvNullToString(dgvKhung.GetFocusedRowCellDisplayText(colLVH_ten));

                this.Selected = true;

                this.Close();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            try
            {               
                this.Close();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }
    }
}